package com.project.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("user")
public class UserController {

    @RequestMapping("login")
    public String login(String userName, String pwd, String code,HttpServletRequest req){

        String userCode = req.getSession().getAttribute("userCode").toString();

        if (userCode.equalsIgnoreCase(code) == false){
            return "errorCode";
        }

        if ("java".equals(userName) && "123".equals(pwd)){
            return "ok";
        }
        return "no";
    }
}
